        <link rel="stylesheet" type="text/css" href="css/fitem.css">
        <script type="text/javascript">
            var url;
            function newBarang(){
                $('#dlgBarang').dialog('open').dialog('setTitle','Barang Baru');
                $('#fmBarang').form('clear');
                url = 'pages/barang/barang_new.php';
            }
            function editBarang(){
                var row = $('#dgBarang').datagrid('getSelected');
                if (row){
                    $('#dlgBarang').dialog('open').dialog('setTitle','Edit Barang');
                    $('#fmBarang').form('load',row);
                    url = 'pages/barang/barang_update.php?id='+row.idBarang;
                }
            }
            function saveBarang(){
                $('#fmBarang').form('submit',{
                    url: url,
                    onSubmit: function(){
                        return $(this).form('validate');
                    },
                    success: function(result){
                        var result = eval('('+result+')');
                        if (result.success){
                            $('#dlgBarang').dialog('close');		// close the dialog
                            $('#dgBarang').datagrid('reload');	// reload the user data
                            $.messager.show({
                                title: 'Sukses',
                                msg: result.msg
                            });
                        } else {
                            $.messager.show({
                                title: 'Error',
                                msg: result.msg
                            });
                        }
                    }
                });
            }
            function removeBarang(){
                var row = $('#dgBarang').datagrid('getSelected');
                if (row){
                    $.messager.confirm('Confirm','Are you sure you want to remove this barang?',function(r){
                        if (r){
                            $.post('pages/barang/barang_remove.php',{id:row.idBarang},function(result){
                                if (result.success){
                                    $('#dgBarang').datagrid('reload');	// reload the user data
                                    $.messager.show({	
                                        title: 'Sukses',
                                        msg: result.msg
                                    });
                                } else {
                                    $.messager.show({	// show error message
                                        title: 'Error',
                                        msg: result.msg
                                    });
                                }
                            },'json');
                        }
                    });
                }
            }
            function doSearchDataBarang() 
            {
                    var postThis = $('#fcaribarang').serialize();
                    $('#dgBarang').datagrid('reload',{
                            ref:postThis
                    });
            }
        </script>
    
	<table id="dgBarang" title="Daftar Barang" class="easyui-datagrid"
			url="pages/barang/barang_getdata.php"
			toolbar="#toolbarBarang" pagination="true"
			rownumbers="true" singleSelect="true" fitColumns="true">
		<thead>
			<tr>
				<th field="barcode" width="80">Part Number</th>
				<th field="namaBarang" width="250">Nama Barang</th>
				<th field="namaKategoriBarang" width="90">Kategori Barang</th>
				<th field="namaSatuanBarang" width="80">Satuan Barang</th>
				<th field="jumBarang" width="50" align="right">Stock</th>
				<th field="hargaJual" width="100" align="right">Harga Jual</th>
                                <th field="namaSupplier" width="250">Supplier</th>
				<th field="last_update" width="65">Last Update</th>
				<th field="namaRak" width="65">Lokasi</th>
			</tr>
		</thead>
	</table>
	<div id="toolbarBarang" style='padding:5px;height:auto'>
            <table>
                <tr>
                    <td>
                        <form id='fcaribarang'>	
                            Nama Barang: 
                            <input class='easyui-validatebox' type='text' name='filternamaBarang' id='filternamabarang'>
                            Kategori Barang: 
                            <input class='easyui-combobox' 
                                   url="pages/combodata.php?field=kategori"
                                   valueField="idKategoriBarang"
                                   textField="namaKategoriBarang"
                                   panelHeight="250px">
                            Satuan Barang: 
                            <input class="easyui-combobox" 
                                   url="pages/combodata.php?field=satuan"
                                   valueField="idSatuanBarang"
                                   textField="namaSatuanBarang">
                            <a href='javascript:void(0)' class='easyui-linkbutton' iconCls='icon-search' onclick='doSearchDataBarang()'>Cari Data</a>
                            <br><br>
                            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="newBarang()">New</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" onclick="editBarang()">Edit</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" onclick="removeBarang()">Remove</a>
                        </form>
                    </td>	
                </tr>
            </table>
	</div>

    <div id="dlgBarang" class="easyui-dialog" style="width:700px;height:auto;padding:10px;" closed="true" modal="true">
        <form id="fmBarang" method="post">
            <div class="fitem">
                <label>Part Number</label>
                <input class="easyui-validatebox" type="text" style="width:280px" name="barcode" id="barcode" required><br>
            </div>
            <div class="fitem" >
                <label>Nama Barang</label>
                <input class="easyui-validatebox" style="width:520px" name="namaBarang" id="namaBarang" required ><br>
            </div>
            <br><hr><br>
            <div class="fitem" >
                <label>Kategori</label>
                <input class="easyui-combobox" 
                       style="width:180px" 
                       name="idKategoriBarang" 
                       id="idKategoriBarang"
                       url="pages/combodata.php?field=kategori"
                       valueField="idKategoriBarang"
                       textField="namaKategoriBarang"
                       panelHeight="250px"
                       required >
                <label>Jumlah Barang</label>
                        <input type="text" class="easyui-validatebox" name="jumBarang" id="jumBarang">
            </div>
            <div class="fitem">
                <label>Satuan</label>
                <input class="easyui-combobox" 
                       style="width:180px" 
                       name="idSatuanBarang" 
                       id="idSatuanBarang" 
                       url="pages/combodata.php?field=satuan"
                       valueField="idSatuanBarang"
                       textField="namaSatuanBarang"
                       panelHeight="auto"
                       required >
                <label>Harga Jual</label>
                        <input type="text" class="easyui-validatebox" name="hargaJual" id="hargaJual">
            </div>
            <div class="fitem">
                <label>Supplier</label>
                <input class="easyui-combobox" 
                       style="width:180px" 
                       name="idSupplier" 
                       id="idSupplier" 
                       url="pages/combodata.php?field=supplier"
                       valueField="idSupplier"
                       textField="namaSupplier"
                       panelHeight="auto"
                       required ><label></label>
            </div>
            <br>
            <div class="fitem">
                <label></label><a href="#" class="easyui-linkbutton" onclick="saveBarang()">Save</a>
            </div>
        </form>
    </div>
